package com.dnzx.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.dnzx.framework.page.PageResult;
import org.springframework.stereotype.Service;

import com.dnzx.dao.IBannerDao;
import com.dnzx.model.BannerBO;
import com.dnzx.service.IBannerService;

/**
 * Banner管理
 */
@Service
public class BannerServiceImpl implements IBannerService {

    @Resource
    private IBannerDao bannerDao;

    @Override
    public void save(BannerBO bannerBO) throws Exception {
        this.bannerDao.save(bannerBO);
    }

    @Override
    public void delete(Long id) throws Exception {
        this.bannerDao.delete(id);
    }

    @Override
    public void update(BannerBO bannerBO) throws Exception {
        this.bannerDao.update(bannerBO);
    }

    @Override
    public BannerBO get(Long id) {
        return this.bannerDao.get(id);
    }

    @Override
	public BannerBO get(BannerBO bannerBO) {
		// TODO Auto-generated method stub
		return null;
	}

    @Override
    public List<BannerBO> queryList(BannerBO bannerBO) {
        return this.bannerDao.queryList(bannerBO);
    }

    @Override
    public PageResult<List<BannerBO>> queryPage(BannerBO bannerBO, PageResult<List<BannerBO>> pageResult) {
    	int totalRows = this.bannerDao.queryCount(bannerBO);
        pageResult.setTotalRows(totalRows);
        pageResult.setCurrentPage(bannerBO.getCurrentPage());
        pageResult.setPageSize(bannerBO.getPageSize());
		List<BannerBO> records = this.bannerDao.queryPage(pageResult.getPageSize(), pageResult.getStartRow(), bannerBO);
		pageResult.setT(records);
		return pageResult;
    }

}
